package com.chenliwu.demo.collection;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author chenlw 2021-12-15
 * @since 1.0.0
 */
public class ConcurrentHashMapTest {

    private static Map<String, UserVo> userVoMap = new ConcurrentHashMap<>();

    public static void main(String[] args) {

        // 初始化5W个用户
        int testNum = 100000;
        for (int i = 1; i <= testNum; i++) {
            String userid = "userid" + i;
            String userAccount = "userAccount" + i;
            String username = "username" + i;
            String userType = "userType" + i;
            userVoMap.put(userid, new UserVo(userid, userAccount, username, userType));
        }
        System.out.println(userVoMap.size());
    }

    static class UserVo {

        public UserVo(String userid, String userAccount, String username, String userType) {
            this.userid = userid;
            this.userAccount = userAccount;
            this.username = username;
            this.userType = userType;
        }

        private String userid;

        private String userAccount;

        private String username;

        private String userType;

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        public String getUserAccount() {
            return userAccount;
        }

        public void setUserAccount(String userAccount) {
            this.userAccount = userAccount;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getUserType() {
            return userType;
        }

        public void setUserType(String userType) {
            this.userType = userType;
        }
    }

}
